#include "pch.h"
#include "Factories.h"
#include "Helper.h"

using namespace DXBase;

ID2D1Factory1* Factories::GetD2DFactory()
{
	static ID2D1Factory1* pFac = nullptr;
	if (!pFac)
	{
		D2D1_FACTORY_OPTIONS options;
		ZeroMemory(&options, sizeof(D2D1_FACTORY_OPTIONS));
#if defined(_DEBUG)
		// If the project is in a debug build, enable Direct2D debugging via SDK Layers.
		options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
#endif
	    HR2Ex(D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, __uuidof(ID2D1Factory1), &options, (void**)&pFac));
	}
	return pFac;
}
IDWriteFactory1* Factories::GetDWriteFactory()
{
	static IDWriteFactory1* pFac = nullptr;
	if (!pFac)
	{
		HR2Ex(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,__uuidof(IDWriteFactory),(IUnknown**)&pFac));
	}
	return pFac;
}
IWICImagingFactory2* Factories::GetWicFactory()
{
	static IWICImagingFactory2* pFac = nullptr;
	if (!pFac)
	{
		HR2Ex(CoCreateInstance(CLSID_WICImagingFactory,nullptr,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pFac)));
	}
	return pFac;
}
